﻿using T4UtilityBelt.DataDesigns;
using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Controls.Renderers.Windows
{
    public class BoolRenderer : PropertyRenderer<BoolControl, IBoolRenderer, BoolProperty>, IBoolRenderer
    {
        protected override void OnRenderUiXmlContentInput(BoolControl control, CodeWriter writer)
        {
            // <CheckBox Controls:HelpText.Text="<#=name#>tt" IsChecked="{Binding Entry.<#=name#>,Mode=TwoWay}" />
            writer.WriteBeginTag("CheckBox");

            RenderControlAttributes(control, writer);

            //writer.WriteAttribute("IsChecked", string.Format(@"{{Binding {0},  Mode=TwoWay}}", GetBindingContext(control)));

            writer.WriteFullEnd();
        }

        protected override void OnRenderUiXmlContentReadOnly(BoolControl control, CodeWriter writer)
        {
            //<TextBlock  Text="{Binding  Entry.<#=name#>}" />
            writer.WriteBeginTag("TextBlock");

            if (control.Style == null)
            {
                writer.WriteAttribute("Style", "{StaticResource ReadonlyTextBlock}");
            }
            else
            {
                writer.WriteAttributeFormat("Style", @"{{StaticResource {0}}}", control.Style);
            }

            //writer.WriteAttribute("Text", string.Format(@"{{Binding {0}, Converter={{StaticResource booleanToSymbol}}}}", GetBindingContext(control)));

            writer.WriteFullEnd();
        }
    }
}